﻿using Adalbertus.BudgetPlanner.Domain;
using Adalbertus.BudgetPlanner.Domain.Repositories;
using Adalbertus.BudgetPlanner.Infrastructure;
using Adalbertus.BudgetPlanner.Services;
using Caliburn.Micro;
using Castle.Core;
using Castle.MicroKernel.Registration;
using Castle.Windsor;

namespace Adalbertus.BudgetPlanner
{
    internal class ApplicationContainer : WindsorContainer
    {
        public ApplicationContainer()
        {
            Register(
                Component.For<IWindowManager>().ImplementedBy<WindowManager>().LifeStyle.Is(LifestyleType.Singleton),
                Component.For<IEventAggregator>().ImplementedBy<EventAggregator>().LifeStyle.Is(LifestyleType.Singleton)
            );

            Register(AllTypes.FromAssemblyNamed("Adalbertus.BudgetPlanner.ViewModels").Pick().
                Configure(x => x.LifeStyle.Is(LifestyleType.Singleton)));
            Register(Component.For<IRepositoryFactory>().ImplementedBy<RepositoryFactory>().LifeStyle.Is(LifestyleType.Singleton));
            //Register(Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>());
            Register(Component.For<IUnitOfWorkProvider>().ImplementedBy<UnitOfWorkProvider>().LifeStyle.Is(LifestyleType.Singleton));
            Register(Component.For<IBudgetService>().ImplementedBy<BudgetService>().LifeStyle.Is(LifestyleType.Singleton));
            Register(Component.For<ICashFlowService>().ImplementedBy<CashFlowService>().LifeStyle.Is(LifestyleType.Singleton));
            Register(Component.For<IIncomeService>().ImplementedBy<IncomeService>().LifeStyle.Is(LifestyleType.Singleton));
            Register(Component.For<ISavingService>().ImplementedBy<SavingService>().LifeStyle.Is(LifestyleType.Singleton));
            Register(Component.For<IBudgetPlanService>().ImplementedBy<BudgetPlanService>().LifeStyle.Is(LifestyleType.Singleton));
        }
    }
}
